package com.larsgard.gedviewer.server.storage.entities;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.larsgard.gedviewer.shared.entities.UserTree;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class JDOUserTree implements PersitenceCapable {

    private static final long serialVersionUID = 7689199309854332388L;

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

    @Persistent
    private String treeId;
    @Persistent
    private String gedFileId;
    @Persistent
    private String userMail;
    @Persistent
    private Date createdDate;
    @Persistent
    private String password;
    @Persistent
    private boolean processed;
    @Persistent
    private int numberOfPersons;
    @Persistent
    private int numberOfPersonsProcessed;

    public void setUserMail(String userMail) {
	this.userMail = userMail;
    }

    public String getUserMail() {
	return userMail;
    }

    public void setCreatedDate(Date createdDate) {
	this.createdDate = createdDate;
    }

    public Date getCreatedDate() {
	return createdDate;
    }

    public void setPassword(String password) {
	this.password = password;
    }

    public String getPassword() {
	return password;
    }

    public void setProcessed(Boolean processed) {
	this.processed = processed;
    }

    public Boolean getProcessed() {
	return processed;
    }

    public void setNumberOfPersons(int numberOfPersons) {
	this.numberOfPersons = numberOfPersons;
    }

    public int getNumberOfPersons() {
	return numberOfPersons;
    }

    public void setNumberOfPersonsProcessed(int numberOfPersonsProcessed) {
	this.numberOfPersonsProcessed = numberOfPersonsProcessed;
    }

    public int getNumberOfPersonsProcessed() {
	return numberOfPersonsProcessed;
    }

    public void setGedFileId(String gedFileId) {
	this.gedFileId = gedFileId;
    }

    public String getGedFileId() {
	return gedFileId;
    }

    public void setTreeId(String treeId) {
	this.treeId = treeId;
    }

    public String getTreeId() {
	return treeId;
    }

    @Override
    public Key getKey() {
	return key;
    }

    @Override
    public void setKey(Key key) {
	this.key = key;
    }

    public UserTree getUserTree() {
	UserTree tree = new UserTree();
	tree.setTreeId(treeId);
	tree.setPassword(password);
	tree.setCreatedDate(createdDate);
	tree.setGedFileId(gedFileId);
	tree.setNumberOfPersons(numberOfPersons);
	tree.setNumberOfPersonsProcessed(numberOfPersonsProcessed);
	tree.setProcessed(processed);
	tree.setUserMail(userMail);
	return tree;
    }
}
